//package com.yunhe.common.controller.base;
//
//import com.yunhe.common.domain.base.AlarmStatus;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.DomainList;
//import com.yunhe.common.model.PageParam;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.common.model.base.AlarmStatusDTO;
//import com.yunhe.common.service.base.AlarmStatusService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//import java.util.Map;
//import java.util.Optional;
//
///**
// * 告警条件Controller
// * @desc 告警条件控制类定义
// * @author duanxiaoyong
// */
//@Api(value = "alarmStatus",description = "告警条件维护", tags = {"Base_AlarmStatus"})
//@RestController
//@RequestMapping("/alarmStatuses")
//public class AlarmStatusController {
//
//    @Autowired
//    private AlarmStatusService alarmStatusService;
//
//    /**
//     * 新增告警状态
//     * @param alarmStatus 告警状态对象
//     */
//    @ApiOperation("新增告警状态")
//    @RequestMapping(method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(@RequestBody AlarmStatus alarmStatus)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        AlarmStatusDTO newAlarmStatus = alarmStatusService.createAlarmStatus(alarmStatus);
//        return new ResponseEntity<>(new ResultObject<>(newAlarmStatus), HttpStatus.OK);
//    }
//
//    @ApiOperation("批量新增告警状态")
//    @RequestMapping(value = "/batch", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(@RequestBody DomainList<AlarmStatus> domainList)
//            throws ArgumentErrorException, UniqueConstraintsException {
//        List<AlarmStatus> alarmStatusList = domainList.getList();
//        List<AlarmStatusDTO> results = alarmStatusService.createAlarmStatus(alarmStatusList);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//
//    /**
//     * 根据ID删除告警状态
//     * @param id 告警状态ID
//     */
//    @ApiOperation("根据ID删除告警状态")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "告警状态ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(@PathVariable("id") Long id) {
//        alarmStatusService.deleteAlarmStatus(id);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//
//    /**
//     * 更新告警状态
//     * @param id 告警状态ID
//     * @param alarmStatus 告警状态对象
//     */
//    @ApiOperation("更新告警状态")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "告警状态ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(@PathVariable("id") Long id,
//                                            @RequestBody AlarmStatus alarmStatus)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        alarmStatus.setId(id);
//        AlarmStatusDTO newAlarmStatus = alarmStatusService.updateAlarmStatus(alarmStatus);
//        return new ResponseEntity<>(new ResultObject<>(newAlarmStatus), HttpStatus.OK);
//    }
//
//    /**
//     * 更新告警状态
//     * @param id 告警状态ID
//     * @param code 告警状态代码
//     * @param name 告警状态编号
//     * @param title 告警状态名称
//     * @param sn 排序序号
//     * @param activity 是否可用
//     */
//    @ApiOperation("更新告警状态")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "告警状态ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "code", value = "告警状态代码", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "告警状态编号", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "title", value = "告警状态名称", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "sn", value = "排序序号", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "activity", value = "是否可用", dataType = "boolean", paramType = "query"),
//            @ApiImplicitParam(name = "bit", value = "警告位", dataType = "int", paramType = "query")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(@PathVariable("id") Long id,
//                                              @RequestParam("code") Optional<Long> code,
//                                              @RequestParam("name") Optional<String> name,
//                                              @RequestParam("title") Optional<String> title,
//                                              @RequestParam("sn") Optional<Long> sn,
//                                              @RequestParam("activity") Optional<Boolean> activity,
//                                              @RequestParam("bit") Optional<Long> bit,
//                                              @RequestParam("devTitle") Optional<String> devTitle,
//                                              @RequestParam("condition") Optional<String> condition,
//                                              @RequestParam("alarm") Optional<Boolean> alarm,
//                                              @RequestParam("limitValue") Optional<Double> limitValue,
//                                              @RequestParam("stationId") Optional<Long> stationId,
//                                              @RequestParam("alarmTypeId") Optional<Long> alarmTypeId,
//                                              @RequestParam("alarmLevelId") Optional<Long> alarmLevelId)
//            throws ArgumentErrorException, ObjectNotFoundException, UniqueConstraintsException {
//        AlarmStatusDTO newAlarmStatus = alarmStatusService.updateAlarmStatus(id, code, name, title, sn, activity, bit,
//                devTitle, condition, alarm, limitValue, stationId, alarmTypeId, alarmLevelId);
//        return new ResponseEntity<>(new ResultObject<>(newAlarmStatus), HttpStatus.OK);
//    }
//
//    /**
//     * 根据告警状态ID获得告警状态
//     * @param id 告警状态ID
//     */
//    @ApiOperation("根据告警状态ID获得告警状态")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "告警状态ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> get(@PathVariable("id") Long id) {
//        AlarmStatusDTO alarmStatus = alarmStatusService.findByAlarmStatusId(id);
//        return new ResponseEntity<>(new ResultObject<>(alarmStatus), HttpStatus.OK);
//    }
//
//    /**
//     * 根据条件获得告警状态列表
//     */
//    @ApiOperation("根据条件获得告警状态列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "stationIds", value = "电站ID", dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "queryStr", value = "查询条件", dataType = "string", paramType = "query")
//    })
//    @RequestMapping(method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search(@RequestParam("stationIds") Optional<List<Long>> stationIds,
//                                               @RequestParam("queryStr") Optional<String> queryStr,
//                                               @ModelAttribute PageParam pageParam) {
//        Iterable<AlarmStatusDTO> results = alarmStatusService.findAlarmStatus(stationIds.orElse(null), queryStr.orElse(null), pageParam);
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//
////
////    /**
////     * 绑定告警类型（根据代码）
////     * @param systemId 系统ID
////     * @param code 告警状态代码
////     * @param alarmTypeCode 告警类型代码
////     */
////    @ApiOperation("绑定告警类型（根据代码）")
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path"),
////            @ApiImplicitParam(name = "code", value = "告警状态代码", required = true, dataType = "long", paramType = "path"),
////            @ApiImplicitParam(name = "alarmTypeCode", value = "告警类型代码", required = true, dataType = "long", paramType = "path")
////    })
////    @RequestMapping(value = "/byCode/{code}/alarmStatus/{alarmTypeCode}", method = RequestMethod.POST)
////    public ResponseEntity<ResultObject> bindAlarmTypeByCode(@PathVariable("systemId") Long systemId,
////                                                              @PathVariable("code") Long code,
////                                                              @PathVariable("alarmTypeCode") Long alarmTypeCode)
////            throws DatabaseProcessException {
////        alarmStatusService.bindAlarmTypeByCode(code, alarmTypeCode);
////        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
////    }
////
////    /**
////     * 解绑告警类型（根据代码）
////     * @param systemId 系统ID
////     * @param code 告警状态代码
////     * @param alarmTypeCode 告警类型代码
////     */
////    @ApiOperation("解绑告警类型（根据代码）")
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path"),
////            @ApiImplicitParam(name = "code", value = "告警状态代码", required = true, dataType = "long", paramType = "path"),
////            @ApiImplicitParam(name = "alarmTypeCode", value = "告警类型代码", required = true, dataType = "long", paramType = "path")
////    })
////    @RequestMapping(value = "/byCode/{code}/alarmStatus/{alarmTypeCode}", method = RequestMethod.DELETE)
////    public ResponseEntity<ResultObject> unbindAlarmTypeByCode(@PathVariable("systemId") Long systemId,
////                                                                @PathVariable("code") Long code,
////                                                                @PathVariable("alarmTypeCode") Long alarmTypeCode)
////            throws DatabaseProcessException {
////        alarmStatusService.unbindAlarmTypeByCode(code, alarmTypeCode);
////        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
////    }
////
////    /**
////     * 更新告警类型（根据代码）
////     * @param systemId 系统ID
////     * @param code 告警状态代码
////     * @param alarmTypeCodes 告警类型代码
////     */
////    @ApiOperation("更新告警类型（根据代码）")
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path"),
////            @ApiImplicitParam(name = "code", value = "告警状态代码", required = true, dataType = "long", paramType = "path"),
////            @ApiImplicitParam(name = "alarmTypeCodes", value = "告警类型代码（以逗号间隔）", required = true, dataType = "long", paramType = "path")
////    })
////    @RequestMapping(value = "/byCode/{code}/alarmType", method = RequestMethod.PUT)
////    public ResponseEntity<ResultObject> updateAlarmTypeByCode(@PathVariable("systemId") Long systemId,
////                                                              @PathVariable("code") Long code,
////                                                              @RequestParam("alarmTypeCodes") List<Long> alarmTypeCodes)
////            throws ArgumentErrorException, DatabaseProcessException {
////        alarmStatusService.updateAlarmTypeByCode(code,alarmTypeCodes);
////        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
////    }
//
////    /**
////     * 根据点号获取告警状态
////     * @param pointNumberList 点号列表
////     */
////    @ApiOperation("根据点号获取告警状态")
////    @ApiImplicitParams({
////            @ApiImplicitParam(name = "pointNumberList", value = "点号列表", required = true, dataType = "long", paramType = "query")
////    })
////    @RequestMapping(value = "/byPointNumber/alarmStatus", method = RequestMethod.GET)
////    public ResponseEntity<ResultObject> getAlarmStatusByPointNumber(@RequestParam("pointNumberList") List<Long> pointNumberList)
////            throws ObjectNotFoundException {
////        Map<Long, List<String>> results = alarmStatusService.getAlarmStatusByPointNumber(pointNumberList);
////        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
////    }
//
//    /**
//     * 查询全部状态
//     */
//    @ApiOperation("查询全部状态")
//    @RequestMapping(value = "/all", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> findAll() {
//        Map<Long, Map<Long, String>> results = alarmStatusService.findAll();
//        return new ResponseEntity<>(new ResultObject<>(results), HttpStatus.OK);
//    }
//
//    @ApiOperation("获取告警格式")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "告警状态ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/format/byId/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getFormat(@PathVariable("id") Long id) {
//        String result = alarmStatusService.getFormat(id);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
//
//    @ApiOperation("获取告警阈值")
//    @RequestMapping(value = "/limitValue/abnormalId/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getLimitValue(@PathVariable("id") Long id) {
//        AlarmStatusDTO alarmStatus = alarmStatusService.findByAlarmStatusId(id);
//        Double result;
//        if (alarmStatus == null) {
//            result = null;
//        } else {
//            result = alarmStatus.getLimitValue();
//        }
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
//
//    @ApiOperation("根据名称获得告警状态对象")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "name", value = "告警名称", required = true, dataType = "string", paramType = "path")
//    })
//    @RequestMapping(value = "/byName/{name}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getByName(@PathVariable("name") String name) {
//        AlarmStatusDTO alarmStatus = alarmStatusService.findByName(name);
//        return new ResponseEntity<>(new ResultObject<>(alarmStatus), HttpStatus.OK);
//    }
//
//    @ApiOperation("获取告警值")
//    @RequestMapping(value = "/realValueById/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getRealValue(@PathVariable("id") Long id) {
//        Double result = alarmStatusService.getRealValue(id);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
//
//    @ApiOperation("获取告警类型")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "代码", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/type/byId/{id}", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> getTypeById(@PathVariable("id") Long id) {
//        String result = alarmStatusService.getTypeById(id);
//        return new ResponseEntity<>(new ResultObject<>(result), HttpStatus.OK);
//    }
//
//    /**
//     * 批量更新告警级别
//     * @param alarmLevelId 告警级别ID
//     * @param idList 异常名称ID列表
//     */
//    @ApiOperation("批量更新告警级别")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "alarmLevelId", value = "告警等级ID", required = true, dataType = "long", paramType = "query"),
//            @ApiImplicitParam(name = "idList", value = "异常ID列表", required = true, dataType = "long", paramType = "query"),
//    })
//    @RequestMapping(value = "/alarmLevel/batch", method = RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> updateAlarmLevel(@RequestParam("alarmLevelId") Long alarmLevelId,
//                                                         @RequestParam("idList") List<Long> idList) {
//        alarmStatusService.updateAlarmLevel(alarmLevelId, idList);
//        return new ResponseEntity<>(new ResultObject<>(null), HttpStatus.OK);
//    }
//}
